package com.huawei.appmarket.service.store.awk.card;

import android.content.Context;
import android.graphics.Bitmap;
import android.text.TextUtils;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.LinearLayout.LayoutParams;
import android.widget.TextView;
import com.huawei.appgallery.foundation.card.base.card.BaseDistCard;
import com.huawei.appgallery.foundation.ui.framework.cardkit.bean.CardBean;
import com.huawei.appmarket.service.store.awk.bean.BigBannerItemBean;
import java.util.Locale;
import o.azb;
import o.cgz;
import o.chy;
import o.Logger;
import o.dof;
import o.dok;
import o.ContentManager;
import o.eib;
import o.epv;
import o.eqx;
import o.eqz;
import o.erq;
import o.evx;
import o.ewm.d;
import o.ewm.i;
import o.ewm.j;
import o.ewm.n;

public class BigImageBannerItemCard extends BaseDistCard implements eqz {
    private LinearLayout ʻ;
    private ImageView ʼ;
    private TextView ʽ;
    private TextView ˊॱ;
    private ImageView ˋ;
    private TextView ˋॱ;
    private ImageView ˏॱ;
    private TextView ͺ;
    private TextView ॱˊ;
    private TextView ॱˋ;
    private LinearLayout ॱॱ;
    private TextView ᐝ;

    public BigImageBannerItemCard(Context context) {
        super(context);
    }

    public cgz ˏ(View view) {
        this.ˋ = (ImageView) view.findViewById(j.ˊʹ);
        this.ʼ = (ImageView) view.findViewById(j.ॱᐨ);
        this.ʻ = (LinearLayout) view.findViewById(j.ˈꜞ);
        this.ʽ = (TextView) view.findViewById(j.ˈꞌ);
        this.ᐝ = (TextView) view.findViewById(j.ˈㆍ);
        this.ॱॱ = (LinearLayout) view.findViewById(j.ʻㆍ);
        this.ˊॱ = (TextView) view.findViewById(j.ʻᐨ);
        this.ॱˊ = (TextView) view.findViewById(j.ʳॱ);
        this.ˏॱ = (ImageView) view.findViewById(j.ʻˉ);
        this.ˋॱ = (TextView) view.findViewById(j.ʻᵔ);
        this.ͺ = (TextView) view.findViewById(j.ʻߵ);
        this.ॱˋ = (TextView) view.findViewById(j.ʻᴵ);
        int ˎ = ˎ();
        int dimensionPixelSize = this.ʼॱ.getResources().getDimensionPixelSize(d.ˋʻ);
        int dimensionPixelSize2 = this.ʼॱ.getResources().getDimensionPixelSize(d.ॱˋ);
        ˎ = epv.ˎ(this.ʼॱ, ˎ, dimensionPixelSize);
        view.setLayoutParams(new LayoutParams(ˎ, ((int) (((float) ˎ) * epv.ʽ())) + dimensionPixelSize2));
        ʽ(view);
        return this;
    }

    public void ॱ(final chy o_chy) {
        OnClickListener anonymousClass1 = new evx(this) {
            final /* synthetic */ BigImageBannerItemCard ˋ;

            public void ˋ(View view) {
                o_chy.ˏ(0, this.ˋ);
            }
        };
        View ˉ = ˉ();
        if (ˉ != null) {
            ˉ.setOnClickListener(anonymousClass1);
        }
    }

    private int ˎ() {
        return eib.ˊॱ();
    }

    public void ˏ(CardBean cardBean) {
        super.ˏ(cardBean);
        if (cardBean instanceof BigBannerItemBean) {
            BigBannerItemBean bigBannerItemBean = (BigBannerItemBean) cardBean;
            String str = (String) this.ˋ.getTag();
            if (dof.ˋ(str) || !str.equals(bigBannerItemBean.ॱˌ())) {
                this.ॱॱ.setVisibility(8);
                this.ʻ.setVisibility(8);
                if (bigBannerItemBean.ʽᐝ() == 18) {
                    this.ॱॱ.setVisibility(0);
                    if (bigBannerItemBean.ʼˊ().equals("1")) {
                        this.ˏॱ.setVisibility(0);
                        eqx.ˏ(this.ˏॱ, bigBannerItemBean.ʻᐝ(), "app_default_icon");
                    } else {
                        this.ˏॱ.setVisibility(8);
                    }
                    this.ˊॱ.setText(bigBannerItemBean.ʻˊ());
                    this.ॱˊ.setText(bigBannerItemBean.ˎͺ());
                } else if (bigBannerItemBean.ʽᐝ() == 8 || bigBannerItemBean.ʽᐝ() == 9) {
                    this.ʻ.setVisibility(0);
                    this.ʽ.setText(bigBannerItemBean.ˎͺ());
                    this.ᐝ.setText(bigBannerItemBean.v_());
                }
                if (this.ॱॱ.getVisibility() == 0 && bigBannerItemBean.ꞌ() == 2 && !TextUtils.isEmpty(bigBannerItemBean.ʹ())) {
                    this.ˋॱ.setVisibility(0);
                    this.ॱˋ.setVisibility(0);
                    this.ͺ.setVisibility(0);
                    float floatValue = Float.valueOf(bigBannerItemBean.ʹ()).floatValue();
                    this.ˋॱ.setText(String.format(Locale.ENGLISH, "%.1f", new Object[]{Float.valueOf(floatValue)}));
                    this.ˋॱ.setContentDescription(this.ʼॱ.getString(n.יˊ, new Object[]{r0}));
                    this.ॱˋ.setText(ˏ(bigBannerItemBean.ʻˋ()));
                } else {
                    this.ˋॱ.setVisibility(8);
                    this.ˋॱ.setContentDescription(null);
                    this.ॱˋ.setVisibility(8);
                    this.ͺ.setVisibility(8);
                }
                ˎ(bigBannerItemBean);
                this.ˋ.setTag(bigBannerItemBean.ॱˌ());
            }
        }
    }

    private void ˎ(BigBannerItemBean bigBannerItemBean) {
        if (TextUtils.isEmpty(bigBannerItemBean.ʼᐝ())) {
            this.ʼ.setVisibility(4);
            eqx.ˎ(this.ˋ, bigBannerItemBean.ॱˌ(), "image_default_icon", this, true);
            return;
        }
        this.ʼ.setVisibility(0);
        eqx.ˎ(this.ʼ, bigBannerItemBean.ʼᐝ(), "iconflag", this, true);
        eqx.ˏ(this.ˋ, bigBannerItemBean.ॱˌ(), "image_default_icon");
    }

    public void ॱ(Bitmap bitmap) {
        if (bitmap != null) {
            try {
                int ʼˋ;
                int ॱ;
                if (this.ˊᐝ instanceof BigBannerItemBean) {
                    BigBannerItemBean bigBannerItemBean = (BigBannerItemBean) this.ˊᐝ;
                    if (bigBannerItemBean.ʼˋ() != 0) {
                        ʼˋ = bigBannerItemBean.ʼˋ();
                    } else {
                        ॱ = erq.ॱ("", Bitmap.createBitmap(bitmap, 0, (bitmap.getHeight() * 2) / 3, bitmap.getWidth(), bitmap.getHeight() / 3));
                        bigBannerItemBean.ʽ(ॱ);
                        ʼˋ = ॱ;
                    }
                } else {
                    ʼˋ = erq.ॱ("", Bitmap.createBitmap(bitmap, 0, (bitmap.getHeight() * 2) / 3, bitmap.getWidth(), bitmap.getHeight() / 3));
                }
                boolean ˏ = erq.ˏ(ʼˋ);
                ॱ = -16777216;
                float ˋ = azb.ˋ(this.ʼॱ, d.ߴ);
                if (ˏ) {
                    ॱ = -1;
                    ˋ = azb.ˋ(this.ʼॱ, d.ՙ);
                }
                if (this.ॱॱ.getVisibility() == 0) {
                    this.ˊॱ.setTextColor(ॱ);
                    this.ॱˊ.setTextColor(ॱ);
                    this.ॱˊ.setAlpha(ˋ);
                    this.ˋॱ.setTextColor(ॱ);
                    this.ͺ.setTextColor(ॱ);
                    this.ॱˋ.setTextColor(ॱ);
                    this.ॱˋ.setAlpha(ˋ);
                } else if (this.ʻ.getVisibility() == 0) {
                    this.ʽ.setTextColor(ॱ);
                    this.ᐝ.setTextColor(ॱ);
                    this.ʽ.setAlpha(ˋ);
                }
            } catch (IllegalStateException e) {
                Logger.e("BigImageBannerItemCard", e.toString());
            }
        }
    }

    protected String ˏ(String str) {
        int parseInt = Integer.parseInt(str);
        if (!"zh".equals(dok.ᐝ()) && !"bo".equals(dok.ᐝ()) && !"ug".equals(dok.ᐝ())) {
            return ˏ(parseInt);
        }
        if (parseInt >= 10000000) {
            parseInt /= 10000000;
            return ContentManager.getInstant().getContext().getResources().getQuantityString(i.ˋॱ, parseInt, new Object[]{String.valueOf(parseInt)});
        } else if (((float) parseInt) >= 10000.0f) {
            String format = String.format(Locale.ENGLISH, "%.1f", new Object[]{Float.valueOf(((float) parseInt) / 10000.0f)});
            return ContentManager.getInstant().getContext().getResources().getQuantityString(i.ˋॱ, (int) r0, new Object[]{format});
        } else {
            return ContentManager.getInstant().getContext().getResources().getQuantityString(i.ʻ, parseInt, new Object[]{Integer.valueOf(parseInt)});
        }
    }

    private String ˏ(int i) {
        String quantityString = ContentManager.getInstant().getContext().getResources().getQuantityString(i.ʻ, i, new Object[]{Integer.valueOf(i)});
        String format;
        if (((float) i) >= 1000000.0f) {
            format = String.format(Locale.ENGLISH, "%.1f", new Object[]{Float.valueOf(((float) i) / 1000000.0f)});
            return ContentManager.getInstant().getContext().getResources().getQuantityString(i.ᐝ, (int) r0, new Object[]{format});
        } else if (((float) i) < 1000.0f) {
            return quantityString;
        } else {
            format = String.format(Locale.ENGLISH, "%.1f", new Object[]{Float.valueOf(((float) i) / 1000.0f)});
            return ContentManager.getInstant().getContext().getResources().getQuantityString(i.ˋॱ, (int) r0, new Object[]{format});
        }
    }
}
